<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="common/common_head :: commonHead('任务反馈表管理')"></head>
</head>
<body class="auth-user">
<div class="layui-fluid">
    <div class="layui-row larryms-panel auth-user-add" style="overflow: auto">
        <form class="layui-form" id="taskForm">
            <input type="hidden" id="id" name="id" th:value="${entity?.id}"/>
            <div class="layui-form-item">
                <label for="type" class="layui-form-label">
                    <span class="x-red">*</span> 任务类型                 </label>
                <div class="layui-input-block">
                        <input type="text" id="type" name="type" lay-verify="type"
                               autocomplete="off" class="layui-input larry-input" th:value="${entity?.type}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="descr" class="layui-form-label">
                    <span class="x-red">*</span> 任务描述                 </label>
                <div class="layui-input-block">
                        <input type="text" id="descr" name="descr" lay-verify="descr"
                               autocomplete="off" class="layui-input larry-input" th:value="${entity?.descr}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="taskTime" class="layui-form-label">
                    <span class="x-red">*</span> 任务时间                 </label>
                <div class="layui-input-block">
                        <input type="text" id="taskTime" name="taskTime" lay-verify="taskTime"
                           autocomplete="off" class="layui-input larry-input" th:value="${entity?.taskTime} == null ? '' : ${#dates.format(entity?.taskTime, 'yyyy-MM-dd HH:mm:ss')}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="finishTime" class="layui-form-label">
                    <span class="x-red">*</span> 完成时间                 </label>
                <div class="layui-input-block">
                        <input type="text" id="finishTime" name="finishTime" lay-verify="finishTime"
                           autocomplete="off" class="layui-input larry-input" th:value="${entity?.finishTime} == null ? '' : ${#dates.format(entity?.finishTime, 'yyyy-MM-dd HH:mm:ss')}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="result" class="layui-form-label">
                    <span class="x-red">*</span> 任务处理结果                 </label>
                <div class="layui-input-block">
                        <textarea class="layui-textarea" style="width: 92%" id="result" name="result" lay-verify="result" th:text="${entity?.result}"></textarea>
                        <!--<input type="text" id="result" name="result" lay-verify="result"
                               autocomplete="off" class="layui-input larry-input" th:value="${entity?.result}"/>-->
                </div>
            </div>
            <!--<div class="layui-form-item">
                <label for="address" class="layui-form-label">
                    <span class="x-red">*</span> 地址                 </label>
                <div class="layui-input-block">
                        <input type="text" id="address" name="address" lay-verify="address"
                               autocomplete="off" class="layui-input larry-input" th:value="${entity?.address}"/>
                </div>
            </div>-->

            <!--<div style="padding: 9px 25px;">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>附件上传</legend>
                </fieldset>

                <div class="layui-upload" style="margin-bottom: 50px">
                    <button type="button" class="layui-btn" id="uploadBtn">图片上传</button>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览图：
                        <div class="layui-upload-list" id="demo2"></div>
                    </blockquote>
                </div>

                <button type="button" class="layui-btn" id="test5"><i class="layui-icon"></i>上传视频</button>
            </div>-->


            <div class="layui-form-item">
                .
            </div>
    <div th:if="${param.detail == null}">
        <div class="larryms-layer-btn">
            <a class="layui-btn layui-btn layui-btn-sm left" lay-submit=""
               lay-filter="add" id="submit" th:attr="data-url=@{/admin/task/save}">保存</a>
            <a class="layui-btn layui-btn layui-btn-sm  layui-btn-danger" id="resetBtn">重置</a>
            <a class="layui-btn layui-btn layui-btn-sm  layui-btn-primary" id="close">关闭</a>
        </div>
    </div>
    </form>
    </div>
</div>
<script type="text/javascript" th:src="@{/static/larryms/layui/layui.js}"/>
<script type="text/javascript" th:inline="javascript">/*<![CDATA[*/
var bathPath = /*[[@{/}]]*/ "/";
layui.config({
    version: ui.version,
    layertype:2,
    base: bathPath + 'static/larryms/',  //实际使用时，建议改成绝对路径
    rightMenu: "none" // false关闭，设置为custom时使用自定义，不使用默认menu
}).extend({
    larry:'js/base'
}).use(['larry','form','table','laydate','custom','upload'], function () {
    var form = layui.form , larryms = layui.larryms, $ = layui.$, beone = layui.custom, upload = layui.upload;
    var formRules = {};
            formRules.type = function (value) {
                if (value.trim() == "") {
                    return  "任务类型不能为空!" ;
                }
            }
            formRules.descr = function (value) {
                if (value.trim() == "") {
                    return  "任务描述不能为空!" ;
                }
            }
            layui.laydate.render({  id:"taskTime", elem:"#taskTime"});
            formRules.taskTime = function (value) {
                if (value.trim() == "") {
                    return  "任务时间不能为空!" ;
                }
            }
    //自定义验证规则
    form.verify(formRules);

    var indexFre = parent.layer.getFrameIndex(window.name);
    $('#close').click(function () {
        parent.layer.close(indexFre);
    });
    $('#resetBtn').on('click', function() {
        $('#taskForm')[0].reset();
    });
    //监听提交
    form.on('submit(add)', function (data) {
        var url = $(this).data("url");
        $.post(url, data.field, function(res) {
            if (res.code == "success") {
                larryms.msg(res.desc);
                parent.table.reload('taskList', {});
                parent.layer.close(indexFre);
            }
        });
        return false;
    });
    form.render();

    //多图片上传
    upload.render({
        elem: '#uploadBtn'
        ,url: '/upload/'
        ,multiple: true
        ,before: function(obj){
            //预读本地文件示例，不支持ie8
            obj.preview(function(index, file, result){
                $('#demo2').append('<img class="preview-img" src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img"></img>')
            });
        }
        ,done: function(res){
            //上传完毕
        }
    });
});
/*]]>*/</script>
</body>

<style>
    .preview-img {
        height: 100px;
        width: 100px;
    }
</style>
</html>